/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package managed.util;

import javax.ejb.EJB;
import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSessionListener;

/**
 *
 * @author Danilo
 */
public class SessionManager implements HttpSessionListener{

    @EJB
    private Users us;
    @Override
    public void sessionCreated(HttpSessionEvent se) {
        
    }

    @Override
    public void sessionDestroyed(HttpSessionEvent se) {
        String username = se.getSession().getAttribute("id").toString();
        if(us != null && us.getOnlineUsers() != null && us.getOnlineUsers().containsKey(username))
        us.getOnlineUsers().remove(username);
    }
    
}
